home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UEvent.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  5.7 KB  |  198 lines  |  [TEXT/MPS ]

  1. // UEvent.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4.  
  5. #ifndef __UEVENT__
  6. #define __UEVENT__
  7.  
  8. // MacApp
  9.  
  10. #ifndef __UOBJECT__
  11. #include "UObject.h"
  12. #endif
  13.  
  14. // Toolbox
  15.  
  16. #ifndef __EVENTS__
  17. #include <Events.h>
  18. #endif
  19.  
  20.  
  21. //----------------------------------------------------------------------------------------
  22. // Constants
  23. //----------------------------------------------------------------------------------------
  24.  
  25. const short kPriorityLowest = 127;
  26.     // Low priority commands are considered last
  27.  
  28. const short kPriorityLow = kPriorityLowest - 32;
  29.     // Low priority commands are considered last
  30.  
  31. const short kPriorityNormal = 64;
  32.     // Normal priority: command default priority
  33.  
  34. const short kPriorityHigh = kPriorityNormal - 32;
  35.     // High priority commands take precedence
  36.  
  37. const short kPriorityHighest = 0;
  38.     // High priority commands take precedence
  39.  
  40.  
  41. //----------------------------------------------------------------------------------------
  42. // Typedefs
  43. //----------------------------------------------------------------------------------------
  44.  
  45. typedef char EventPriority;
  46.     //  Event priorities
  47.  
  48.  
  49. //----------------------------------------------------------------------------------------
  50. // Forward and external class declarations. 
  51. //----------------------------------------------------------------------------------------
  52.  
  53. class TEventHandler;
  54.  
  55.  
  56. //----------------------------------------------------------------------------------------
  57. // TEvent
  58. //----------------------------------------------------------------------------------------
  59.  
  60. class TEvent : public TObject
  61. {
  62.     MA_DECLARE_CLASS;
  63.     
  64. public:
  65.  
  66.     TEvent();
  67.         // Constructor
  68.         
  69.     virtual ~TEvent();
  70.         // Write out a message if we are attempting to free an event that is still on the
  71.         // event queue.
  72.  
  73.     void IEvent(EventNumber itsEventNumber,
  74.                 TEventHandler* itsSource,
  75.                 TEventHandler* itsHandler);
  76.  
  77.     virtual Boolean ShouldFreeOnCompletion();
  78.     
  79.     virtual Boolean IsReadyToPost();
  80.         // True if the event can be posted to the event queue.  Default returns true.
  81.  
  82.     virtual Boolean IsReadyToExecute();
  83.  
  84.     virtual Boolean IsRecurring();
  85.  
  86.  
  87.     virtual TEventHandler* GetHandler();
  88.  
  89.     virtual void Process();
  90.  
  91. #if qDebug
  92.     virtual void ReportEvent();
  93. #endif
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // data members
  97. //----------------------------------------------------------------------------------------
  98. public:
  99.     TEventHandler* fSource;
  100.  
  101.     TEventHandler* fHandler;                    // The handler for this event
  102.  
  103.     EventNumber fIdentifier;                    // Can be a many-to-one mapping of fIdentifier to
  104.                                                 // TEvent
  105.  
  106.     EventPriority fPriority;                    // How this event should be prioritized if
  107.                                                 // it has do compete on a prioritized
  108.                                                 // basis for execution. kNormalPriority is
  109.                                                 // the Default. Most programs won't have
  110.                                                 // to mess with this.
  111.  
  112.     Boolean fAffectsMenus;                        // True means the menus must be setup
  113.                                                 // after the event
  114.  
  115. };
  116.  
  117.  
  118. //----------------------------------------------------------------------------------------
  119. // TToolboxEvent
  120. //----------------------------------------------------------------------------------------
  121.  
  122. class TToolboxEvent : public TEvent
  123. {
  124.     MA_DECLARE_CLASS;
  125.     
  126. public:
  127.     TToolboxEvent();        
  128.         // Constructor
  129.  
  130.     virtual ~TToolboxEvent();
  131.         // Destructor
  132.         
  133.     Boolean IToolboxEvent(TEventHandler* itsHandler, const EventRecord& theEvent);
  134.         // returns TRUE if the event was the first of a two event sequence
  135.  
  136.     void AddSecondaryKeyEvent(const EventRecord& theEvent);
  137.  
  138.     Boolean IsButtonPressed() const;
  139.         // Was the button pressed?
  140.         
  141.     Boolean IsCommandKeyPressed() const;
  142.         // Was Command key depressed?
  143.         
  144.     Boolean IsShiftKeyPressed() const;
  145.         // Was Shift key depressed?
  146.         
  147.     Boolean IsAlphaLock() const;
  148.         // Was Alpha Lock depressed?
  149.         
  150.     Boolean IsOptionKeyPressed() const;
  151.         // Was Option key depressed?
  152.         
  153.     Boolean IsControlKeyPressed() const;
  154.         // Was Control key depressed?
  155.         
  156.     Boolean IsAutoKeyEvent() const;
  157.         // True if this was an auto key event
  158.  
  159.     virtual void Process();        //override
  160.         // Call gApplication->DoToolBoxEvent directly to dispatch the event
  161.  
  162.     virtual Boolean RemoveDependenciesOnFree(); // override
  163.         // TToolboxEvents don't have any dependents so do go through the overhead
  164.         
  165. #if qDebug
  166.     virtual void ReportEvent();
  167. #endif
  168.  
  169. //----------------------------------------------------------------------------------------
  170. // data members
  171. //----------------------------------------------------------------------------------------
  172. public:
  173.     EventRecord fEventRecords[2];                // IF a key event, The primary original
  174.                                                 // packed ToolBox event record (and secondary, when this is
  175.                                                 // a multibyte character)
  176.  
  177.     CStr2 fText;                                // IF a key event, the character that the event
  178.                                                 // translates to. length of 1 for single byte
  179.                                                 // characters and length of 2 for 16 bit characters
  180.  
  181.     const EventRecord& fEventRecord;            // Reference to the first record, left in for compatibility
  182.     const unsigned char& fCharacter;            // Reference to the first character, left in for compatibility
  183.  
  184.     ScriptCode fKeyScript;                        // The KeyScript at the time the event was retrieved
  185.  
  186.     short fKeyCode;                                // IF a key event the virtual key code
  187.                                                 // that the event translates to
  188.  
  189.     short fClickCount;                            // 0 = event was not a mouse down; 1-N = #
  190.                                                 // of multiple clicks
  191.     Boolean fDoubleEvent;                        // TRUE if there is a second event stored herein (fEventRecords[1])
  192. };
  193.  
  194.  
  195. #endif
  196.  
  197.  
  198.